//---------------------------------------------------------------------------
#ifndef LoanShopH
#define LoanShopH
//---------------------------------------------------------------------------
#include <vcl.h>
#include "LoanArticle.h";

class Shop
{
	static const int NUM_ARTICLES = 25;  // store capacity of shop
	private:
	AnsiString id;		 // the id of this shop
	AnsiString name;     // the name of this shop
	Article** articles;  // holds the articles of this shop,
						 // the names of the articles in this array are unique.
	int nrOfArticles;    // the number of articles
	int nrOfPurchases;	 // the number of purchases
	int purchaseIdList[NUM_ARTICLES]; // the list of articles to sell
	int purchaseQtList[NUM_ARTICLES]; // the list of quantity to sell

	/*
	If there exists an article with articleID id,
	it returns the index of that article in the array articles,
	else it returns -1
	same for the second method only this one checks the purchase
	*/
	int getIndexOfArticle(int id);
	int getIndexOfPurchase(int id);

	public:
	//constructors

	/*
	this constructor creates a Shop-object with a name
	as specified with the parameter of this constructor.
	*/
	Shop(AnsiString id, AnsiString name);

	/*
	this destructor makes sure there are no memory leaks
	*/
	~Shop();

	
	//methods (functions)

	/*
	returns the article on index i in the array articles
	i should have a value between 0 and nrOfArticles (0<=i<nrOfArticles)
	the same for the second method but this one checks for the
	articles in the purchase array
	*/
	Article* getArticleAtIndex(int i);
	Article* getPurchaseAtIndex(int i);

	/*
	Get the id/quantity of a purchase at index i
	*/
	int getPurchaseIdAtIndex(int i);
    int getPurchaseQtAtIndex(int i);

	/*
	some get functions
	*/
	AnsiString getID();
	AnsiString getName();
	int getCapacity();
	int getNrOfArticles();
	int getNrOfPurchases();

	/*
	If there exists already an article with name nm or if
	nrOfArticles>=NUM_ARTICLES the function addArticle returns false.
	In the other case an article with id, name, nrOfItems, kind and price
	as specified with the parameters of the function,
	is added to the array, nrOfArticles is incremented by 1
	and the function returns true.
	*/
	bool addArticle(int id, AnsiString nm, int nrOfItems, AnsiString kind, double price, double deposit);

	/*
	The method soldSome() checks if the nrOfItems is bigger than the amount to remove.
	If so, the number of items of that article is decreased by amount
	and the return value is true. If not, the return value is false.
	The method unsoldSome() is just the the opposite.
	The method unSoldAll() just clears all purchases and add them back to the stock.
	The method clearAllPurchases() just clears all purchases without adding them to the stock.
	The method totalPrice() returns the total price.
	*/
	bool soldSome(int id, int amount);
	bool unsoldSome(int id, int amount);
	void unsoldAll();
	void clearAllPuchases();
	double getTotalPrice();

	//new function for loan shop
	bool unsoldBroken(int id, int amount);

	//*** A method to make the loan shop work
	bool insertGuestLoanToPurchase(int id, int qt);

    /*
	The function sortAllArticlesByName will sort the articles in the array
	by their name, descending.
	*/
    void sortAllArticlesByName();

	/*
	The function sortAllArticlesBySalesValue will sort the articles in the array
	by their sales value, descending.
	*/
	void sortAllArticlesBySalesValue();

	/*
	The function sortAllArticlesByKind will sort the articles in the array
	by their kind.
	*/
	void sortAllArticlesByKind();
};
//---------------------------------------------------------------------------
#endif
